
#include "registerwindow.h"
#include "registerwindow.ui"
#include "usermanager.h"

RegisterWindow::RegisterWindow(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::RegisterWindow)
{
    ui->setupUi(this);
}

RegisterWindow::~RegisterWindow()
{
    delete ui;
}

void RegisterWindow::on_registerButton_clicked()
{
    QString username = ui->usernameLineEdit->text();
    QString password = ui->passwordLineEdit->text();

    UserManager userManager;
    if (userManager.createUser(username, password)) {
        emit registrationResult(true);
        accept();
    } else {
        ui->statusLabel->setText("Registration failed. Please choose a different username.");
    }
}
